package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.view.ViewGroup;


import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.view.entity.MenuEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.ScreenUtil;

import java.util.List;

/**
 * Created by WYJ on 2020/8/26.
 */
@Deprecated
public class Packers3MenuAdapter extends BaseRecycleAdapter<MenuEntity<Object>> {

    private int mItemWidth;

    public Packers3MenuAdapter(Context context, List<MenuEntity<Object>> datas) {
        super(context, R.layout.item_menu_packers3, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, MenuEntity<Object> objectMenuEntity) {
        holder.setBinding(BR.viewModel, objectMenuEntity);
        //getItemWidth(holder);
    }

    private void getItemWidth(ItemViewHolder holder) {
        ViewGroup.LayoutParams layoutParams = holder.getmBinding().getRoot().getLayoutParams();
        if (mItemWidth == 0) {
            if (getDatas().size() < 5) {//处理居中
                mItemWidth = (ScreenUtil.getDisplayWidth() - ScreenUtil.dip2px(10f)) / getDatas().size();
            } else {
                mItemWidth = (ScreenUtil.getDisplayWidth() - ScreenUtil.dip2px(10f)) / 5;
            }
        }
        layoutParams.width = mItemWidth;
        holder.getmBinding().getRoot().setLayoutParams(layoutParams);
    }
}
